public class Verkauf { private Liste posten; private void add(Ware w, int c ) { Liste hl = new Liste(new Warenbestand(w, c)); if ( posten == null ) { posten = hl; } else { posten.append(hl); } } public void transfer(Warenlager source, Ware w, int c) { Liste b; for (b = source.bestand; b != null; b = b.next) { if ( ((Warenbestand)b.data).ware == w ) { if( ((Warenbestand)b.data).count >= c ) { ((Warenbestand)b.data).count -= c; add(w, c); } else { System.err.print("Nicht genĂ¼gend Ware vorhanden\n"); } return; } } } public String toString() { Liste p; String r = ""; for (p = posten; p != null; p = p.next) { r += p.data.toString() + "\n"; } r += String.format("%52.2f\n", wert()); return r; } public double wert() { double r = 0.0; Liste b; for (b = posten; b != null; b = b.next) { r += ((Warenbestand) b.data).wert(); } return r; } }